/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * AnalyticalPanel.java
 *
 * Created on Feb 10, 2009, 6:24:37 PM
 */
package view.panels.analytical;

import controller.Controller;
import java.awt.Color;
import java.util.Vector;
import jgf.Attribute;
import jgf.beans.ArcBean;
import jgf.beans.GraphBean;
import jgf.beans.NodeBean;
import view.panels.JGSPanel;

/**
 * 
 * @author Marcos Garcia Ortega <a href="mailto:thiamath@gmail.com">&lt;thiamath@gmail.com&gt;</a>
 */
public class AnalyticalPanel extends JGSPanel {

	//private IGraph graph;
	private Vector nodeNames;

	/** Creates new form AnalyticalPanel */
	public AnalyticalPanel() {
		initComponents();
		nodeNames = new Vector();
	}

	public AnalyticalPanel(GraphBean graph) {
	//	this.graph = graph;
		initComponents();
	}

	/** This method is called from within the constructor to
	 * initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is
	 * always regenerated by the Form Editor.
	 */
	@SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        aPTab = new javax.swing.JTabbedPane();
        arcsPanel = new view.panels.analytical.ArcsPanel();
        nodesPanel = new view.panels.analytical.NodesPanel();

        setLayout(new java.awt.GridLayout(1, 0));

        aPTab.addTab("tab1", arcsPanel);
        aPTab.addTab("tab2", nodesPanel);

        add(aPTab);
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTabbedPane aPTab;
    private view.panels.analytical.ArcsPanel arcsPanel;
    private view.panels.analytical.NodesPanel nodesPanel;
    // End of variables declaration//GEN-END:variables

	//<editor-fold defaultstate="collapsed" desc="Observer Cascade Recalls">
	//////////////////////////////
	// OBSERVER CASCADE RECALLS //
	//////////////////////////////
	
	public void insertArc(ArcBean arc) {
		arcsPanel.insertArc(arc);
	}

	public void deleteArc(ArcBean arc) {
		arcsPanel.deleteArc(arc);
	}

	public void updateArc(ArcBean arc) {
		//this.graph.updateArc(arc);
	}

	public void insertNode(NodeBean node) {
		nodesPanel.insertNode(node);

		// WIPE
		//Vector nodeNames = new Vector();
		//nodeNames.add(" ");

		//for (Node inode : graph.getNodeList()) {
		//    nodeNames.add(inode.getIndex());
		//}
		nodeNames.add(node.getId());

		arcsPanel.getFromNodeCB().setModel(new javax.swing.DefaultComboBoxModel(nodeNames));
		arcsPanel.getToNodeCB().setModel(new javax.swing.DefaultComboBoxModel(nodeNames));
	}

	public void deleteNode(NodeBean node) {
		nodesPanel.deleteNode(node);
		//this.graph.deleteNode(node);
	}

	public void updateNode(NodeBean node) {
		//this.graph.updateNode(node);
	}

	public void updateAll(GraphBean graph) {
		//this.graph = new DrawGraph(graph);
	}

	public void addArcAttribute(String name, Integer value) {
		this.arcsPanel.addArcAttribute(name, value);
	}

	public void removeArcAttribute(String name) {
		this.arcsPanel.removeArcAttribute(name);
	}
	
	@Override
	public void setController(Controller controller) {
		super.setController(controller);
		nodesPanel.setController(controller);
		arcsPanel.setController(controller);
	}

	public void loadGraph(GraphBean graph) {
		//this.graph = graph;
		this.nodesPanel.loadGraph(graph);
		this.arcsPanel.loadGraph(graph);
	}

	public void setSource(NodeBean node) {
		throw new UnsupportedOperationException("Not supported yet.");
	}

	public void unsetSource(NodeBean node) {
		throw new UnsupportedOperationException("Not supported yet.");
	}

	public void setSink(NodeBean node) {
		throw new UnsupportedOperationException("Not supported yet.");
	}

	public void unsetSink(NodeBean node) {
		throw new UnsupportedOperationException("Not supported yet.");
	}

	public void addDefaultNodeAttribute(Attribute attribute) {
		throw new UnsupportedOperationException("Not supported yet.");
	}

	public void removeDefaultNodeAttribute(Attribute attribute) {
		throw new UnsupportedOperationException("Not supported yet.");
	}

	public void updateDefaultNodeAttribute(String previousName, Attribute newValue) {
		throw new UnsupportedOperationException("Not supported yet.");
	}

	public void addDefaultArcAttribute(Attribute attribute) {
		throw new UnsupportedOperationException("Not supported yet.");
	}

	public void removeDefaultArcAttribute(Attribute attribute) {
		throw new UnsupportedOperationException("Not supported yet.");
	}

	public void updateDefaultArcAttribute(String previousName, Attribute newValue) {
		throw new UnsupportedOperationException("Not supported yet.");
	}
	//</editor-fold>
}


